package main

import (
	"context"
	"fmt"
	"net/http"
	"net/url"

	"github.com/tencentyun/cos-go-sdk-v5"
)

func main() {
	// 存储桶名称，由 bucketname-appid 组成，appid 必须填入，可以在 COS 控制台查看存储桶名称。 https://console.cloud.tencent.com/cos5/bucket
	// 替换为用户的 region，存储桶 region 可以在 COS 控制台“存储桶概览”查看 https://console.cloud.tencent.com/ ，关于地域的详情见 https://cloud.tencent.com/document/product/436/6224 。
	//u, _ := url.Parse("https://wenwo-audio-dev-1321752346.cos.ap-guangzhou.myqcloud.com")
	bucketNames := []string{"wenwo-office-test-1321752346", "wenwo-audio-test-1321752346", "wenwo-img-test-1321752346", "wenwo-img-dev-1321752346", "wenwo-file-dev-1321752346", "ww-dev-v-out-1321752346", "wenwo-office-dev-1321752346", "wenwo-file-test-1321752346", "wenwo-audio-dev-1321752346", "ww-dev-v-src-1321752346"}
	for _, bucketName := range bucketNames {
		bucketUrl := fmt.Sprintf("https://%s.cos.ap-guangzhou.myqcloud.com", bucketName)
		u, _ := url.Parse(bucketUrl)
		b := &cos.BaseURL{BucketURL: u}
		client := cos.NewClient(b, &http.Client{
			Transport: &cos.AuthorizationTransport{
				SecretID:  "AKIDoV2LRO7jHmDYlpndJpBf1KUQ9mBLZaQ7",
				SecretKey: "fAXnuoY7bu78vY1JVQCY7jU8ZorklfXM",
			},
		})
		v, _, err := client.Bucket.GetDomain(context.Background())
		if err != nil {
			fmt.Println(err)
		}
		fmt.Println(bucketName, v)
	}
}
